package moonstruckdrops.page;

import javax.servlet.http.HttpServletRequest;

import moonstruckdrops.model.BlogBasicParts;
import moonstruckdrops.service.BlogMainService;
import moonstruckdrops.service.GoogleAccountService;
import moonstruckdrops.serviceImpl.BlogMainServiceImpl;
import moonstruckdrops.serviceImpl.GoogleAccoutServiceImpl;

import org.apache.wicket.ResourceReference;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.Link;

public class BlogMainPage extends WebPage{
	
	BlogMainService MainService = new BlogMainServiceImpl();
	BlogBasicParts BlogParts = MainService.BlogMainPageinit();
	
	public BlogMainPage(){
		
		//add(BlogParts.getAuthor());
		
		Link<Void> linkc=new Link<Void>("link"){
			private static final long serialVersionUID = 1L;
			public void onClick(){}
		};
		add(BlogParts.getAuthor());
		add(linkc.add(BlogParts.getBlogTitle()));
		add(BlogParts.getComent());
		add(BlogParts.getProfile());
		add(new Image("ProfileImage",new ResourceReference(BlogMainPage.class,"image.jpg")));
		
		/**
		 *GoogleAccount認証 
		 */
		HttpServletRequest request = getWebRequestCycle().getWebRequest().getHttpServletRequest();
		GoogleAccountService Account = new GoogleAccoutServiceImpl();
		Account.init(request);
		if (Account.AuthCheck()){
			setResponsePage(new ManagementPage(Account));
		}else{
			Account.CreateLoginURL();
			add(Account.AccoutURL("ManagementPageTolink"));
		}
	}
}